﻿package mortal.game.view.lotteryDraw
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.controls.*;
    import fl.data.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class lotteryDrawRecordView extends GSprite
    {
        private var _myRecodeBox:lotteryDrawRecordBox;
        private var _bAreaRecodeList:GTileList;
        private var _rareItemRecord:GTileList;
        protected var _scrollPane1:GScrollPane;
        private var _level:int = -1;

        public function lotteryDrawRecordView()
        {
            return;
        }// end function

        private function getDataProvider() : void
        {
            return;
        }// end function

        public function set panelData(param1:Object) : void
        {
            this._level = param1.level;
            if (this._myRecodeBox)
            {
                this._myRecodeBox.clearData();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawRequestRecord, {type:0, level:this._level}));
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawRequestRecord, {type:1, level:this._level}));
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawRequestRecord, {type:2, level:this._level}));
            return;
        }// end function

        public function updateMyRecord(param1:int) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (param1 != this._level)
            {
                return;
            }
            this._myRecodeBox.dataProvider = this.getMyRecodeListDataProvider();
            this._myRecodeBox.validateNow();
            this._myRecodeBox.drawNow();
            this._scrollPane1.validateNow();
            this._scrollPane1.update();
            this._scrollPane1.verticalScrollPosition = 0;
            return;
        }// end function

        public function updateBAreaRecord(param1:int) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (param1 != this._level)
            {
                return;
            }
            this._bAreaRecodeList.dataProvider = this.getbAreaRecodeListDataProvider();
            return;
        }// end function

        public function updateRareRecord(param1:int) : void
        {
            if (this.isDisposed)
            {
                return;
            }
            if (param1 != this._level)
            {
                return;
            }
            this._rareItemRecord.dataProvider = this.getRareItemRecodeListDataProvider();
            this._rareItemRecord.drawNow();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(14, 24, 270, 546, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.SkillTitle_nameBg, 14, 24, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.SkillTitle_nameBg, 14, 300, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.lotteryDrawMyRecordTxt, 14, 29, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.lotteryDrawBAreaRecordTxt, 14, 305, this));
            this._myRecodeBox = new lotteryDrawRecordBox(10);
            this.addChild(this._myRecodeBox);
            this._bAreaRecodeList = UIFactory.tileList(20, 330, 240, 240, this);
            this._bAreaRecodeList.columnWidth = 240;
            this._bAreaRecodeList.rowHeight = 50;
            this._bAreaRecodeList.horizontalGap = 5;
            this._bAreaRecodeList.setStyle("cellRenderer", lotteryDrawRecodeCellRender);
            this._scrollPane1 = UIFactory.gScrollPanel(20, 55, 260, 240, this);
            this._scrollPane1.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane1.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane1.source = this._myRecodeBox;
            this.addChild(this._scrollPane1);
            this._scrollPane1.update();
            this._rareItemRecord = UIFactory.tileList(-557, 60, 500, 100, this);
            this._rareItemRecord.columnWidth = 50;
            this._rareItemRecord.rowHeight = 50;
            this._rareItemRecord.horizontalGap = 0;
            this._rareItemRecord.direction = GBoxDirection.HORIZONTAL;
            this._rareItemRecord.setStyle("cellRenderer", lotteryDrawRecordRareItemCellRender);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bAreaRecodeList.dispose(param1);
            this._bAreaRecodeList = null;
            this._myRecodeBox.dispose(param1);
            this._rareItemRecord.dispose(param1);
            this._scrollPane1.dispose(param1);
            this._myRecodeBox = null;
            this._rareItemRecord = null;
            this._scrollPane1 = null;
            super.disposeImpl();
            return;
        }// end function

        private function getMyRecodeListDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.lotteryDrawRecord.myRecordInfo;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_1.addItem({recordInfo:_loc_2[_loc_3], recordType:lotteryRecordType.Record_Lottery_Mine});
                _loc_3++;
            }
            return _loc_1;
        }// end function

        private function getbAreaRecodeListDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.lotteryDrawRecord.bAreaRecordInfo;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_1.addItem({recordInfo:_loc_2[_loc_3], recordType:lotteryRecordType.Record_Lottery_BArea});
                _loc_3++;
            }
            return _loc_1;
        }// end function

        private function getRareItemRecodeListDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.lotteryDrawRecord.rareRecordInfo;
            var _loc_3:* = _loc_2.length > 10 ? (10) : (_loc_2.length);
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3)
            {
                
                _loc_1.addItem({recordInfo:_loc_2[_loc_4], recordType:lotteryRecordType.Record_Lottery_Rare});
                _loc_4++;
            }
            return _loc_1;
        }// end function

    }
}
